function SoftPhone() {
    // 坐席登录编号
    this.loginId = '';
    // 坐席姓名
    this.agentName = '';
    // 坐席CTI工号
    this.agentId = '';
    // 坐席CTI工号登录密码
    this.ctiPass = '';
    // 坐席CTI工号签入分机号
    this.extNo = '';
    // 坐席对应操作员工号-交易上送使用
    this.opeNo = '';
    // 坐席所属租户
    this.tenantId = '';
    // 坐席所属租户职场
    this.workPlace = '';
    // 坐席所拥有的技能组
    this.agentgroupList = [];
    // 默认外呼技能组
    this.outboundGroup = '';
    // 软电话应用URL
    this.softPhonePath = '';
    // IVR转接URL
    this.ivrServerPath = '';
    // CTI服务签入链接
    this.ctiConnectors = [];
    // 坐席状态更新URL配置
    this.dealConnectors = '';
    // 坐席监控数据查询地址
    this.httpConnector = '';
    // 坐席监控地址
    this.monitorConnector = '';
    // 外呼示忙原因码
    this.outboundReasonCode = '';
    // 挂机示忙原因码
    this.dropCallReason = '';
    // 示忙原因码-展示在下拉框
    this.notReadyReasons = [];
    // 示忙原因名称-展示在下拉框
    this.notReadyReasonNames = [];
    // 辅助示忙原因码-不展示在下拉框
    this.hiddByteReasons = [];
    // 辅助示忙原因码-不展示在下拉框
    this.hiddByteReasonNames = [];
    // 当前坐席未就绪原因码
    this.currentbusyReason = '';
    // 当前坐席状态
    this.currAgentStatus = '';
    // 保存会话信息和客户信息
    this.sessionMap = {};
    // ucid获取sessionId
    this.ucidMap = {};
    // 当前会话ID
    this.currentSessionId = '';
    // 当前呼叫ucid
    this.currentUcid = '';
    // 当前呼叫ID
    this.currentContactId = '';
    // 外呼生成sessionId变量因子
    this.outboundInd = 0;
    // 转接IVR流程VDN
    this.ivrVdnNo = '';
    // 定时器
    this.timerInterval = null;
    this.cxtime = 0;

    /** 初始化对象值* */
    this.initObj = function (loginId, agentName, agentId, ctiPass, extNo, opeNo, tenantId, workPlace, agentgroupList, outboundGroup, softPhonePath, ivrServerPath, ctiConnectors, dealConnectors, httpConnector, monitorConnector, outboundReasonCode, dropCallReason, notReadyReasons, notReadyReasonNames, hiddByteReasons, hiddByteReasonNames, ivrVdnNo) {
        this.loginId = loginId;
        this.agentName = agentName;
        this.agentId = agentId;
        this.ctiPass = ctiPass;
        this.extNo = extNo;
        this.opeNo = opeNo;
        this.tenantId = tenantId;
        this.workPlace = workPlace;
        this.agentgroupList = agentgroupList;
        this.outboundGroup = outboundGroup;
        this.softPhonePath = softPhonePath;
        this.ivrServerPath = ivrServerPath;
        this.ctiConnectors = ctiConnectors;
        this.dealConnectors = dealConnectors;
        this.httpConnector = httpConnector;
        this.monitorConnector = monitorConnector;
        this.outboundReasonCode = outboundReasonCode;
        this.dropCallReason = dropCallReason;
        this.notReadyReasons = notReadyReasons;
        this.notReadyReasonNames = notReadyReasonNames;
        this.hiddByteReasons = hiddByteReasons;
        this.hiddByteReasonNames = hiddByteReasonNames;
        this.ivrVdnNo = ivrVdnNo;
    };

    /**
       * 判断当前坐席是否存在会话未完成小结
       * return true-存在, false-不存在
       */
    this.isSession = function () {
        for (const pId in this.sessionMap) {
            if (typeof this.sessionMap[pId] !== 'undefined' && this.sessionMap[pId] !== null) {
                const { sessionId } = this.sessionMap[pId];
                if (typeof sessionId !== 'undefined' && sessionId !== null && sessionId.substr(0, 2) !== 'LX' && this.sessionMap[pId].isHangup)// 存在外呼或者呼入会话
                {
                    return true;
                }
            }
        }
        return false;
    };

    /**
       * 判断当前坐席是否在通话中
       * return true-通话中, false-非通话中
       */
    // this.isCalling = function () {
    //   if (station && station.calls && station.calls.activeCall && station.calls.activeCall !== '') {
    //     return true;
    //   }
    //
    //   return false;
    // };

    /**
       * 清除session
       */
    this.clearSession = function (sessionId) {
        if (typeof this.sessionMap[sessionId] !== 'undefined' && this.sessionMap[sessionId] !== null) {
            const { ucid } = this.sessionMap[sessionId];
            const { contactId } = this.sessionMap[sessionId];
            delete this.sessionMap[sessionId];
            delete this.ucidMap[ucid];
            delete this.ucidMap[contactId];
        }
    };

    /**
       * 清除所有session
       */
    this.clearAllSession = function () {
        for (const pId in this.sessionMap) {
            const { sessionId } = this.sessionMap[pId];
            const { ucid } = this.sessionMap[pId];
            const { contactId } = this.sessionMap[pId];
            delete this.sessionMap[sessionId];
            delete this.ucidMap[ucid];
            delete this.ucidMap[contactId];
        }
    };


    /**
       * 签入
       */
    this.connectBtnClick = function () {
        // 签入前清空所有会话
        this.clearAllSession();
        login(this.extNo, this.agentId, this.ctiPass);
    };

    /**
       * 签出
       */
    this.disconnectBtnClick = function () {
        // 签出前判断是否通话中
        if (this.isCalling()) {
            this.showErrorInfo('提示', '通话中，不能签出CTI工号！', true);
        } else {
            // 签出前判断是否有未完成的话后小结
            if (this.isSession()) {
                this.showErrorInfo('提示', '尚未完成话后小结，不允许签出CTI工号！', true);
            } else {
                // 签出前清空所有会话
                this.clearAllSession();
                logout();
            }
        }
    };

    /**
       * 签入或签出
       */
    this.connectOrCheckOutBtnClick = function () {
        if (this.loginOrLogoutBtnLabel() === '签入') {
            this.connectBtnClick();
        } else {
            this.disconnectBtnClick();
        }
    };

    /**
       * 应答（接起）
       */
    this.answerBtnClick = function () {
        answer();
    };

    /**
       * 挂断电话
       */
    this.hangupBtnClick = function () {
        if (this.isCalling()) {
            hangup();
        } else {
            this.showErrorInfo('提示', '非通话中，无需挂断电话！', true);
        }
    };

    /**
       * 示闲（就绪）
       */
    this.IdleBtnClick = function () {
        if (this.isCalling()) {
            this.showErrorInfo('提示', '通话中，不能就绪！', true);
        } else if (this.isSession()) {
            this.showErrorInfo('提示', '尚未完成话后小结，不允许就绪！', true);
        } else {
            // 就绪前清空所有会话
            this.clearAllSession();
            ready();
        }
    };

    /**
       * 示忙（未就绪）
       */
    this.busyBtnClick = function (type) {
        if (type !== this.currentbusyReason) {
            if (this.isCalling()) {
                this.busyListBtnUpdate(this.currentbusyReason);
                this.showErrorInfo('提示', '通话中，不能改变坐席状态！', true);
            } else if (this.isSession()) {
                this.busyListBtnUpdate(this.currentbusyReason);
                this.showErrorInfo('提示', '尚未完成话后小结，不允许改变坐席状态！', true);
            } else if (type === "") {
                //就绪前清空所有会话
                this.clearAllSession();
                ready();
            }
            else {
                notReady(type);
            }
        }
    };

    /**
       * 外拨
       */
    this.dialBtnClick = function (number) {
        if (this.isCalling()) {
            this.showErrorInfo('提示', '通话中，不能外呼电话！', true);
        } else {
            dial(number);
        }
    };

    /**
       * 电话保持
       */
    this.holdOrRetrieveBtnClick = function () {
        if (this.holdBtnLabel() === '保持') {
            if (this.isCalling()) {
                hold();
            } else {
                this.showErrorInfo('提示', '非通话中，不能保持电话！', true);
            }
        } else {
            retrieve();
        }
    };

    /**
       * 电话保持
       */
    this.holdBtnClick = function () {
        if (this.isCalling()) {
            hold();
        } else {
            this.showErrorInfo('提示', '非通话中，不能保持电话！', true);
        }
    };

    /**
       * 电话恢复
       */
    this.retrieveBtnClick = function () {
        if (this.isCalling()) {
            retrieve();
        } else {
            this.showErrorInfo('提示', '非通话中，不能恢复电话！', true);
        }
    };


    /**
       * 转接IVR
       * menuId 转接具体流程配置
       */
    this.tranferIVRBtnClick = function (menuId) {
        if (this.isCalling()) {
            singleStepTransfer(menuId);
        } else {
            this.showErrorInfo('提示', '非通话中，不能转接电话！', true);
        }
    };

    /**
       * 会议转接IVR
       * menuId 转接具体流程配置
       */
    this.conferencetranferIVRBtnClick = function (menuId) {
        if (this.isCalling()) {
            conferenceTransferIVR(menuId);
        } else {
            this.showErrorInfo('提示', '非通话中，不能转接电话！', true);
        }
    };

    /**
       * 转接坐席
       * agentId: 坐席CTI工号
       */
    this.tranferAgentBtnClick = function (agentId) {
        if (this.isCalling()) {
            transferAgent(agentId);
        } else {
            this.showErrorInfo('提示', '非通话中，不能发起转接！', true);
        }
    };

    /**
       * 完成咨询转接
       */
    this.completeTransferBtnClick = function () {
        if (this.isCalling()) {
            completeTransfer();
        } else {
            this.showErrorInfo('提示', '非通话中，不能完成转接！', true);
        }
    };

    /**
       * 坐席会议
       * agentId: 邀请加入会议的坐席CTI工号
       */
    this.conferenceAgentBtnClick = function (agentId) {
        if (this.isCalling()) {
            conferenceAgent(agentId);
        } else {
            this.showErrorInfo('提示', '非通话中，不能发起会议！', true);
        }
    };

    /**
       * 完成咨询会议
       *
       */
    this.completeConferenceBtnClick = function () {
        if (this.isCalling()) {
            completeConference();
        } else {
            this.showErrorInfo('提示', '非通话中，不能完成会议！', true);
        }
    };

    /**
       * 转接技能组
       * skillNoVdn: 要转接的技能组VDN
       */
    this.tranferSkillNoBtnClick = function (skillNoVdn) {
        if (this.isCalling()) {
            skillTransfer(skillNoVdn);
        } else {
            this.showErrorInfo('提示', '非通话中，不能转接技能组！', true);
        }
    };

    /**
       * 转接外线
       * telNo: 要转接的外线号码
       */
    this.transferTelNoBtnClick = function (telNo) {
        if (this.isCalling()) {
            transferTelNo(telNo);
        } else {
            this.showErrorInfo('提示', '非通话中，不能转接外线！', true);
        }
    };

    /**
       * 转接满意度
       *
       */
    this.satisfactionTransferBtnClick = function () {
        if (this.isCalling()) {
            satisfactionTransfer();
        } else {
            this.showErrorInfo('提示', '非通话中，不能转接满意度调查！', true);
        }
    };

    /**
       * 获取签入签出按钮标签
       *
       */
    this.loginOrLogoutBtnLabel = function () {
        return getLoginOrLogoutBtnLabel();
    };

    /**
       * 签入签出按钮状态更新
       * flag: true-签入，fale-签出
       */
    this.loginOrLogoutBtnStatusUpdate = function (flag) {
        setLoginOrLogoutBtnLabel(flag);
    };

    /**
       * 外呼号码输入框赋值
       * value 外呼号码
       */
    this.dialNumberVal = function (value) {
        setDialNumberVal(value);
    };

    /**
       * 外呼号码输入框状态更新
       * flag: true-可用，fale-不可用
       */
    this.dialNumberStatusUpdate = function (flag) {
        setDialNumberStatus(flag);
    };

    /**
       * 外呼按钮状态更新
       * flag: true-可用，fale-不可用
       */
    this.outBoundBtnStatusUpdate = function (flag) {
        setOutBoundBtnStatus(flag);
    };

    /**
       * 就绪按钮状态更新
       * flag: true-可用，fale-不可用
       */
    this.idleBtnStatusUpdate = function (flag) {
        setIdleBtnStatus(flag);
    };

    /**
       * 根据小休码更新下拉框选项值
       */
    this.busyListBtnUpdate = function (busyCode) {
        setBusyListBtn(busyCode, this.notReadyReasons, this.notReadyReasonNames);
    };

    /**
       * 重置小休码下拉框选项重置
       */
    this.busyListBtnReset = function () {
        resetBusyListBtn(this.notReadyReasons, this.notReadyReasonNames);
    };

    /**
       * 小休码下拉框状态更新
       * flag: true-可用，fale-不可用
       */
    this.busyListBtnStatusUpdate = function (flag) {
        setBusyListBtnStatus(flag);
    };

    /**
       * 接听按钮状态更新
       * flag: true-可用，fale-不可用
       */
    this.answerBtnStatusUpdate = function (flag) {
        setAnswerBtnStatus(flag);
    };

    /**
       * 挂断按钮状态更新
       * flag: true-可用，fale-不可用
       */
    this.hangupBtnStatusUpdate = function (flag) {
        setHangupBtnStatus(flag);
    };

    /**
       * 获取保持按钮标签
       *
       */
    this.holdBtnLabel = function () {
        return getHoldBtnLabel();
    };

    /**
       * 更新保持按钮标签
       * title 标签名称
       */
    this.holdBtnLabelUpdate = function (title) {
        setHoldBtnLabel(title);
    };

    /**
       * 更新保持状态更新
       * flag: true-可用，fale-不可用
       */
    this.holdBtnStatusUpdate = function (flag) {
        setHoldBtnStatus(flag);
    };

    /**
       * 坐席状态标签更新
       * title 标签名称
       */
    this.agentStatusTimeLabelUpdate = function (title) {
        setAgentStatusTimeLabel(title);
    };

    /**
       * 挂机后其他操作
       *
       */
    this.callDropAfter = function (sessionId) {
        // 挂机后更新操作，例如弹出话后小结等
    };

    this.formateTime = function (value) {
        let hour = 0; let minute = 0; let
            second = 0;
        hour = Math.floor(value / 3600);
        minute = Math.floor(value / 60 % 60);
        second = Math.floor(value % 60);
        if (hour < 10) {
            hour = `0${hour}`;
        }
        if (minute < 10) {
            minute = `0${minute}`;
        }
        if (second < 10) {
            second = `0${second}`;
        }
        return result = `${hour}:${minute}:${second}`;
    };

    /**
       * 坐席状态标签更新计时
       * msg 状态描述名称
       */
    this.agentStatusTimeUpdate = function (msg) {
        if (this.timerInterval !== null) // 如果已存在计数器，则先停止
        {
            window.clearInterval(this.timerInterval);
        }
        this.cxtime = (new Date()).getTime(); // 初始化状态开始时间
        function updateStatusTime() {
            const labelStr = `${msg}   ${top.softphone.formateTime(((new Date()).getTime() - top.softphone.cxtime) / 1000)}`;
            top.softphone.agentStatusTimeLabelUpdate(labelStr);
        }
        this.timerInterval = setInterval(updateStatusTime, 1000);
    };


    /**
       * 振铃弹屏-打开一个新会话
       * jsonData: 会话数据
       */
    this.openNewSession = function (jsonData) {
        top.softphone.currentSessionId = jsonData.sessionId;
        this.showErrorInfo('振铃弹屏', jsonData.sessionId, true);
    };

    /**
       * 激活一个已打开的会话
       * sessionId: 会话Id
       */
    this.activeSession = function (sessionId) {
        if (typeof this.sessionMap[sessionId] === 'undefined' || this.sessionMap[sessionId] === null) {
            return;
        }
        top.softphone.currentSessionId = sessionId;
        // this.showErrorInfo("激活会话", sessionId, true);
    };

    /**
       * 关闭一个已打开的会话
       * sessionId: 会话Id
       */
    this.closeSession = function (sessionId) {
        // 关闭会话前先清除会话信息
        this.clearSession(sessionId);
        this.showErrorInfo('关闭会话', sessionId, true);
    };

    /**
       * 根据坐席状态更新按钮
       */
    this.agentStateChangeBtnUpdate = function (agentStateChange) {
        if (this.agentId === agentStateChange.agentId && agentStateChange.deviceId === this.extNo && agentStateChange.srcDeviceId === this.extNo) {
            if (agentStateChange.agentMode === 'Login') // 登录
            {
                this.agentStatusTimeUpdate('签入');
                this.loginOrLogoutBtnStatusUpdate(true);
                this.dialNumberVal('');
                this.dialNumberStatusUpdate(false);
                this.outBoundBtnStatusUpdate(false);
                this.idleBtnStatusUpdate(true);
                this.busyListBtnReset();
                this.busyListBtnStatusUpdate(true);
                this.answerBtnStatusUpdate(false);
                this.hangupBtnStatusUpdate(false);
                this.holdBtnLabelUpdate('保持');
                this.holdBtnStatusUpdate(false);
            }
            if (agentStateChange.agentMode === 'Logout') // 签出
            {
                if (this.timerInterval !== null) // 如果已存在计数器，停止
                {
                    window.clearInterval(this.timerInterval);
                }
                this.agentStatusTimeLabelUpdate('');
                this.loginOrLogoutBtnStatusUpdate(false);
                this.dialNumberVal('');
                this.dialNumberStatusUpdate(true);
                this.outBoundBtnStatusUpdate(false);
                this.idleBtnStatusUpdate(false);
                this.busyListBtnReset();
                this.busyListBtnStatusUpdate(false);
                this.answerBtnStatusUpdate(false);
                this.hangupBtnStatusUpdate(false);
                this.holdBtnLabelUpdate('保持');
                this.holdBtnStatusUpdate(false);
            }
            if (agentStateChange.agentMode === 'Ready') // 就绪
            {
                this.agentStatusTimeUpdate('空闲');
                this.loginOrLogoutBtnStatusUpdate(true);
                this.dialNumberVal('');
                this.dialNumberStatusUpdate(false);
                this.outBoundBtnStatusUpdate(false);
                this.idleBtnStatusUpdate(false);
                this.answerBtnStatusUpdate(false);
                this.hangupBtnStatusUpdate(false);
                this.busyListBtnReset();
                this.busyListBtnStatusUpdate(true);
            }
            if (agentStateChange.agentMode === 'NotReady') // 未就绪
            {
                this.loginOrLogoutBtnStatusUpdate(true);
                this.idleBtnStatusUpdate(true);
                this.busyListBtnStatusUpdate(true);
                if (typeof agentStateChange.reason === 'undefined' || agentStateChange.reason === 'undefined' || agentStateChange.reason === '' || agentStateChange.reason === '0') {
                    this.currentbusyReason = '0';
                    this.busyListBtnReset();
                    this.dialNumberVal('');
                } else {
                    this.currentbusyReason = agentStateChange.reason;
                    for (let i = 0; i < this.notReadyReasons.length; i++) {
                        if (agentStateChange.reason === this.notReadyReasons[i]) {
                            this.agentStatusTimeUpdate(this.notReadyReasonNames[i]);
                            this.busyListBtnUpdate(agentStateChange.reason);
                            this.dialNumberVal('');
                        }
                    }
                    for (let i = 0; i < this.hiddByteReasons.length; i++) {
                        if (agentStateChange.reason === this.hiddByteReasons[i]) {
                            this.agentStatusTimeUpdate(this.hiddByteReasonNames[i]);
                            this.busyListBtnReset(agentStateChange.reason);
                            this.dialNumberVal('');
                        }
                    }
                }
                if (this.currentbusyReason == this.outboundReasonCode)// 外呼
                {
                    this.dialNumberStatusUpdate(true);
                    this.outBoundBtnStatusUpdate(true);
                    this.dialNumberVal('');
                    dialData();
                } else {
                    this.dialNumberVal('');
                    this.dialNumberStatusUpdate(false);
                    this.outBoundBtnStatusUpdate(false);
                }
            }
            if (agentStateChange.agentMode === 'WorkNotReady') // 话后处理
            {
                if (!this.sessionMap[this.ucidMap[this.currentUcid]].isTransferIvr && !this.sessionMap[this.ucidMap[this.currentUcid]].isHangup) {
                    this.agentStatusTimeUpdate('话后');
                }
                this.loginOrLogoutBtnStatusUpdate(true);
                this.dialNumberVal('');
                this.dialNumberStatusUpdate(false);
                this.outBoundBtnStatusUpdate(false);
                this.idleBtnStatusUpdate(true);
                this.busyListBtnReset();
                this.busyListBtnStatusUpdate(false);
                this.answerBtnStatusUpdate(false);
                this.hangupBtnStatusUpdate(false);
            }
        }
    };


    /**
       * 普通提示信息
       * title: 标题
       * text: 信息内容
       * autoHide: 是否自动隐藏提示条 true/false
       * times: 提示框显示时间，单位秒——停留times秒后自动消失
       * hPosition: 水平位置:left, center, right
       * vPosition: 垂直位置：top, center, bottom
       */
    this.showNoticeInfo = function (title, text, autoHide, times, hPosition, vPosition) {
        let allText = '';
        let tmpText = `${title}：${text}`;
        if (tmpText != null && tmpText.length > 75) {
            tmpText = `${tmpText.substr(0, 25)}<br>${tmpText.substr(25, 25)}<br>${tmpText.substr(50, 25)}<br>...`;
        } else if (tmpText.length > 50) {
            tmpText = `${tmpText.substr(0, 25)}<br>${tmpText.substr(25, 25)}<br>${tmpText.substr(50)}`;
        } else if (tmpText.length > 25) {
            tmpText = `${tmpText.substr(0, 25)}<br>${tmpText.substr(25)}`;
        }
        if (text != null && (`${title}：${text}`).length > 25) {
            let i = 1;
            for (i = 1; i * 25 < (`${title}：${text}`).length; i++) {
                allText = `${allText + (`${title}：${text}`).substr((i - 1) * 25, 25)}<br>`;
            }
            allText += (`${title}：${text}`).substr((i - 1) * 25);
        } else {
            allText = `${title}：${text}`;
        }
        const joptions = {
            autoHide: false, // 是否自动隐藏提示条
            clickOverlay: false, // 是否单击遮罩层才关闭提示条
            MinWidth: 200, // 最小宽度
            TimeShown: 3000, // 显示时间：毫秒
            ShowTimeEffect: 500, // 显示到页面上所需时间：毫秒
            HideTimeEffect: 1000, // 从页面上消失所需时间：毫秒
            LongTrip: 100, // 当提示条显示和隐藏时的位移
            HorizontalPosition: 'center', // 水平位置:left, center, right
            VerticalPosition: 'top', // 垂直位置：top, center, bottom
            ShowOverlay: false, // 是否显示遮罩层
            ColorOverlay: '#000', // 设置遮罩层的颜色
            OpacityOverlay: 0.3, // 设置遮罩层的透明度
        };
        if (typeof autoHide !== 'undefined' && autoHide != null) {
            joptions.autoHide = autoHide;
        }
        if (typeof times !== 'undefined' && times != null) {
            joptions.TimeShown = times * 1000;
        }
        if (typeof hPosition !== 'undefined' && hPosition != null) {
            joptions.HorizontalPosition = hPosition;
        }
        if (typeof vPosition !== 'undefined' && vPosition != null) {
            joptions.VerticalPosition = vPosition;
        }
        jNotify(`<span onmouseover='this.innerHTML="${allText}"' onmouseout='this.innerHTML="${tmpText}"' >${tmpText}</span>`, joptions);
    };

    /**
       * 成功提示信息
       * title: 标题
       * text: 信息内容
       * autoHide: 是否自动隐藏提示条 true/false
       * times: 提示框显示时间，单位秒——停留times秒后自动消失
       * hPosition: 水平位置:left, center, right
       * vPosition: 垂直位置：top, center, bottom
       */
    this.showSuccInfo = function (title, text, autoHide, times, hPosition, vPosition) {
        let allText = '';
        let tmpText = `${title}：${text}`;
        if (tmpText != null && tmpText.length > 75) {
            tmpText = `${tmpText.substr(0, 25)}<br>${tmpText.substr(25, 25)}<br>${tmpText.substr(50, 25)}<br>...`;
        } else if (tmpText.length > 50) {
            tmpText = `${tmpText.substr(0, 25)}<br>${tmpText.substr(25, 25)}<br>${tmpText.substr(50)}`;
        } else if (tmpText.length > 25) {
            tmpText = `${tmpText.substr(0, 25)}<br>${tmpText.substr(25)}`;
        }
        if (text != null && (`${title}：${text}`).length > 25) {
            let i = 1;
            for (i = 1; i * 25 < (`${title}：${text}`).length; i++) {
                allText = `${allText + (`${title}：${text}`).substr((i - 1) * 25, 25)}<br>`;
            }
            allText += (`${title}：${text}`).substr((i - 1) * 25);
        } else {
            allText = `${title}：${text}`;
        }
        const joptions = {
            autoHide: false, // 是否自动隐藏提示条
            clickOverlay: false, // 是否单击遮罩层才关闭提示条
            MinWidth: 200, // 最小宽度
            TimeShown: 3000, // 显示时间：毫秒
            ShowTimeEffect: 500, // 显示到页面上所需时间：毫秒
            HideTimeEffect: 1000, // 从页面上消失所需时间：毫秒
            LongTrip: 100, // 当提示条显示和隐藏时的位移
            HorizontalPosition: 'center', // 水平位置:left, center, right
            VerticalPosition: 'top', // 垂直位置：top, center, bottom
            ShowOverlay: false, // 是否显示遮罩层
            ColorOverlay: '#000', // 设置遮罩层的颜色
            OpacityOverlay: 0.3, // 设置遮罩层的透明度
        };
        if (typeof autoHide !== 'undefined' && autoHide != null) {
            joptions.autoHide = autoHide;
        }
        if (typeof times !== 'undefined' && times != null) {
            joptions.TimeShown = times * 1000;
        }
        if (typeof hPosition !== 'undefined' && hPosition != null) {
            joptions.HorizontalPosition = hPosition;
        }
        if (typeof vPosition !== 'undefined' && vPosition != null) {
            joptions.VerticalPosition = vPosition;
        }
        jSuccess(`<span onmouseover='this.innerHTML="${allText}"' onmouseout='this.innerHTML="${tmpText}"' >${tmpText}</span>`, joptions);
    };

    /**
       * 错误提示信息
       * title: 标题
       * text: 信息内容
       * autoHide: 是否自动隐藏提示条 true/false
       * times: 提示框显示时间，单位秒——停留times秒后自动消失
       * hPosition: 水平位置:left, center, right
       * vPosition: 垂直位置：top, center, bottom
       */
    this.showErrorInfo = function (title, text, autoHide, times, hPosition, vPosition) {
        let allText = '';
        let tmpText = `${title}：${text}`;
        if (tmpText != null && tmpText.length > 75) {
            tmpText = `${tmpText.substr(0, 25)}<br>${tmpText.substr(25, 25)}<br>${tmpText.substr(50, 25)}<br>...`;
        } else if (tmpText.length > 50) {
            tmpText = `${tmpText.substr(0, 25)}<br>${tmpText.substr(25, 25)}<br>${tmpText.substr(50)}`;
        } else if (tmpText.length > 25) {
            tmpText = `${tmpText.substr(0, 25)}<br>${tmpText.substr(25)}`;
        }
        if (text != null && (`${title}：${text}`).length > 25) {
            let i = 1;
            for (i = 1; i * 25 < (`${title}：${text}`).length; i++) {
                allText = `${allText + (`${title}：${text}`).substr((i - 1) * 25, 25)}<br>`;
            }
            allText += (`${title}：${text}`).substr((i - 1) * 25);
        } else {
            allText = `${title}：${text}`;
        }
        const joptions = {
            autoHide: false, // 是否自动隐藏提示条
            clickOverlay: false, // 是否单击遮罩层才关闭提示条
            MinWidth: 200, // 最小宽度
            TimeShown: 3000, // 显示时间：毫秒
            ShowTimeEffect: 500, // 显示到页面上所需时间：毫秒
            HideTimeEffect: 1000, // 从页面上消失所需时间：毫秒
            LongTrip: 100, // 当提示条显示和隐藏时的位移
            HorizontalPosition: 'center', // 水平位置:left, center, right
            VerticalPosition: 'top', // 垂直位置：top, center, bottom
            ShowOverlay: false, // 是否显示遮罩层
            ColorOverlay: '#000', // 设置遮罩层的颜色
            OpacityOverlay: 0.3, // 设置遮罩层的透明度
        };
        if (typeof autoHide !== 'undefined' && autoHide != null) {
            joptions.autoHide = autoHide;
        }
        if (typeof times !== 'undefined' && times != null) {
            joptions.TimeShown = times * 1000;
        }
        if (typeof hPosition !== 'undefined' && hPosition != null) {
            joptions.HorizontalPosition = hPosition;
        }
        if (typeof vPosition !== 'undefined' && vPosition != null) {
            joptions.VerticalPosition = vPosition;
        }
        jError(`<span onmouseover='this.innerHTML="${allText}"' onmouseout='this.innerHTML="${tmpText}"' >${tmpText}</span>`, joptions);
    };

    /**
       * 获取IVR流程随路数据
       * sessionId 呼叫编号
       */
    this.getSoftPhoneIVRData = function (sessionId) {
        const url = `${this.softPhonePath}/GetSoftPhone?uui=${sessionId}&ivrServerPath=${this.ivrServerPath}`;
        let data = null;
        try {
            $.ajax({
                type: 'post',
                url,
                dataType: 'json',
                async: false,
                success(jsonData) {
                    console.info(`${top.DateUtil.now()} getSoftPhoneIVRData jsonData:${JSON.stringify(jsonData)}`);
                    if (typeof jsonData !== 'undefined' && jsonData !== null
                        && typeof jsonData.code !== 'undefined' && jsonData.code !== null && jsonData.code === 'OK'
                        && typeof jsonData.success !== 'undefined' && jsonData.success !== null && jsonData.success
                        && typeof jsonData.data !== 'undefined' && jsonData.data !== null) {
                        data = jsonData.data;
                    } else {
                        console.info(`${top.DateUtil.now()}: 获取IVR随路数据异常`);
                        this.showErrorInfo('获取IVR随路数据异常', JSON.stringify(jsonData), true);
                    }
                },
                error(errData) {
                    console.info(`${top.DateUtil.now()}: 获取IVR随路数据失败:${errData}`);
                    this.showErrorInfo('获取IVR随路数据失败', errData, true);
                },
            });
        } catch (err) {
            console.info(`${top.DateUtil.now()}: 获取随路数据失败：${err}`);
            this.showErrorInfo('获取IVR随路数据失败', err, true);
        }
        return data;
    };


    /**
       * 获取客户电话在IVR中的状态
       * sessionId 呼叫编号
       */
    this.checkCallIVRStatus = function (ucid) {
        const t = 5000;// 轮询时间间隔
        let counterFalg = 0; // 异常挂机轮询计数器
        function getCallStatu() {
            let ivrRetJson = top.softphone.getSoftPhoneIVRData(ucid);
            let sessionId = top.softphone.ucidMap[ucid];
            if (ivrRetJson != null) {
                console.info("IVR callstatus:" + ivrRetJson.CALLSTATUS + ", IVR msgid:" + ivrRetJson.MSGID);
                if (ivrRetJson.CALLSTATUS == "1" || ivrRetJson.CALLSTATUS == 1) {
                    console.info("GetSoftPhoneStatus:当前客户电话在还在IVR中！");
                }
                else {
                    if (top.softphone.sessionMap[sessionId].isTransferIvr && ivrRetJson.MSGID == "102") {
                        top.softphone.sessionMap[sessionId].isTransferIvr = false;
                        clearInterval(timer1); //停止轮询
                        counterFalg = 0;
                        top.softphone.sessionMap[sessionId].whoDropCall = "cust";
                        console.info("GetSoftPhoneStatus:获取到客户已挂断电话！");
                        console.info("IVR中客户已挂断电话，进行挂机处理");
                        afterHangup(sessionId);//挂机后操作
                        return;
                    }
                    if (!top.softphone.sessionMap[sessionId].isTransferIvr) // 第一次获取到客户电话离开IVR
                    {
                        console.info("GetSoftPhoneStatus:客户电话已转回！");
                        clearInterval(timer1); //停止轮询
                        counterFalg = 0;

                    }
                    else //客户电话已离开IVR，还没有返回CSR
                    {
                        if (counterFalg < 4) {
                            counterFalg++;
                        }
                        else {
                            top.softphone.sessionMap[sessionId].isTransferIvr = false;
                            clearInterval(timer1); //停止轮询
                            counterFalg = 0;
                            top.softphone.sessionMap[sessionId].whoDropCall = "IVR";
                            console.info("GetSoftPhoneStatus:获取到客户异常挂断电话！");
                            console.info("客户异常挂断电话，进行挂机处理");
                            afterHangup(sessionId);//挂机后操作
                        }
                    }
                }
            }
            else {
                console.info("获取随路数据失败-停止轮询");
                clearInterval(timer1); //停止轮询
                counterFalg = 0;

            }
        }
        var timer1 = setInterval(getCallStatu, t);
    };
    /**
       * 转接IVR前设置随路数据
       * sessionId 呼叫编号
       */
    this.setSoftPhoneData = function (sessionId, menuId, card, IdType, IDNO) {
        const url = `${this.softPhonePath}/setSoftPhoneData?sessionId=${this.sessionMap[sessionId].ucid}&ivrServerPath=${this.ivrServerPath
            }&msgid=101`
            + `&language=${this.sessionMap[sessionId].custData.LANGUAGE
            }&msg=${this.sessionMap[sessionId].custData.MSG
            }&agentId=${this.agentId
            }&extidx=${this.sessionMap[sessionId].custData.EXTIDX
            }&idtype=${IdType
            }&transfbustype=${this.sessionMap[sessionId].custData.TRANSFBUSTYPE
            }&trncnt=${parseInt(this.sessionMap[sessionId].custData.TRNCNT, 10) + 1
            }&anis=${this.sessionMap[sessionId].ani
            }&menuid=${menuId
            }&busitype=${this.sessionMap[sessionId].custData.BUSITYPE
            }&card=${this.sessionMap[sessionId].custData.CARD
            }&bnknbr=${this.sessionMap[sessionId].custData.BNKNBR
            }&trndri=1`
            // + "&userinfo=" + this.sessionMap[sessionId].custData.USERINFO
            + `&dnis=${this.sessionMap[sessionId].dnis
            }&auth=${this.sessionMap[sessionId].custData.AUTH
            }&callstatus=`
            + `&idno=${IDNO
            }&actype=1`;
        let data = false;
        console.info(`${top.DateUtil.now()} setSoftPhoneData url:${url}`);
        try {
            $.ajax({
                type: 'post',
                url,
                dataType: 'json',
                async: false,
                success(jsonData) {
                    console.info(`${top.DateUtil.now()} setSoftPhoneData:${JSON.stringify(jsonData)}`);
                    if (typeof jsonData !== 'undefined' && jsonData !== null
                        && typeof jsonData.code !== 'undefined' && jsonData.code !== null && jsonData.code === 'OK'
                        && typeof jsonData.success !== 'undefined' && jsonData.success !== null && jsonData.success) {
                        data = true;
                        console.info(`${top.DateUtil.now()}: 设置IVR随路数据[${sessionId}]成功!`);
                    } else {
                        console.info(`${top.DateUtil.now()}: 设置IVR随路数据异常`);
                        top.softphone.showErrorInfo('设置IVR随路数据异常', JSON.stringify(jsonData), true);
                    }
                },
                error(errData) {
                    console.info(`${top.DateUtil.now()}: 设置IVR随路数据失败:${errData}`);
                    top.softphone.showErrorInfo('设置IVR随路数据失败', errData, true);
                },
            });
        } catch (err) {
            console.info(`${top.DateUtil.now()}: 设置IVR随路数据失败：${err}`);
            top.softphone.showErrorInfo('设置IVR随路数据失败', err, true);
        }
        return data;
    };

    /**
       * 插入通话历史
       */
    this.insertCallHistory = function (data) {
        $.ajax({
            type: 'POST',
            url: `${top.softphone.softPhonePath}/saveCallHistory`,
            data: {
                sessionId: data.sessionId,
                ucid: data.ucid,
                contactId: data.contactId,
                originalContactId: data.originalContactId,
                callGroup: data.callGroup,
                timestamp: data.timestamp,
                ani: data.ani,
                dnis: data.dnis,
                direction: data.direction,
                sessionType: data.sessionType,
                bnknbr: top.softphone.tenantId,
                busitype: data.custData.BUSITYPE,
                transfbustype: data.custData.TRANSFBUSTYPE,
                menuid: data.custData.MENUID,
                card: data.custData.CARD,
                idtype: data.custData.IDTYPE,
                idno: data.custData.IDNO,
                auth: data.custData.AUTH,
                name: data.custData.NAME,
                enname: data.custData.ENNAME,
                hometelno: data.custData.HOMETELNO,
                mobilephone: data.custData.MOBILEPHONE,
                loginid: top.softphone.loginId,
                agentname: top.softphone.agentName,
                ctino: top.softphone.agentId,
                extno: top.softphone.extNo,
                openo: top.softphone.opeNo,
                custno: data.custData.CUSTNO,
                operationtrajectory: data.custData.OPERATETRAJECT,
            },
            dataType: 'JSON',
            async: false,
            success(result) {
                if (result.code === 'success') {
                    console.info(`${top.DateUtil.now()}: ${result.msg}`);
                } else {
                    console.info(`${top.DateUtil.now()}: code=${result.code}[${result.msg}]`);
                }
            },
            error(errData) {
                console.info(`${top.DateUtil.now()}: 插入呼叫历史异常[${errData}]`);
            },
        });
    };

    /**
       * 更新通话历史
       */
    this.updateCallHistory = function (type, data) {
        $.ajax({
            type: 'POST',
            url: `${top.softphone.softPhonePath}/updateCallHistory`,
            data: {
                type,
                sessionId: data.sessionId,
                ucid: data.ucid,
                isconnected: data.isconnected,
                timestamp: data.timestamp,
                ani: data.ani,
                dnis: data.dnis,
                whoDropCall: data.whoDropCall,
                card: data.custData.CARD,
                idtype: data.custData.IDTYPE,
                idno: data.custData.IDNO,
                auth: data.custData.AUTH,
                name: data.custData.NAME,
                enname: data.custData.ENNAME,
                hometelno: data.custData.HOMETELNO,
                mobilephone: data.custData.MOBILEPHONE,
                custno: data.custData.CUSTNO,
            },
            dataType: 'JSON',
            async: false,
            success(result) {
                if (result.code === 'success') {
                    console.info(`${top.DateUtil.now()}: ${result.msg}`);
                } else {
                    console.info(`${top.DateUtil.now()}: code=${result.code}[${result.msg}]`);
                }
            },
            error(errData) {
                console.info(`${top.DateUtil.now()}: 更新呼叫历史异常[${errData}]`);
            },
        });
    };

    /**
       * 插入转接记录
       * type 转接类型： consultAgent-转接坐席咨询,consultMeeting-会议咨询,transferTelNo-转接外线,transferAgent-转接坐席,transferIVR-转接IVR流程,transferSkill-转接技能组,meeting-会议完成,transferSatisfaction-转接满意度
       */
    this.insertTransferHistory = function (type, data) {
        $.ajax({
            type: 'POST',
            url: `${top.softphone.softPhonePath}/saveTransferCallHistory`,
            data: {
                type,
                sessionId: data.sessionId,
                ucid: data.ucid,
                contactId: data.contactId,
                originalContactId: data.originalContactId,
                callGroup: data.callGroup,
                timestamp: data.timestamp,
                ani: data.ani,
                dnis: data.dnis,
                direction: data.direction,
                sessionType: data.sessionType,
                bnknbr: top.softphone.tenantId,
                busitype: data.custData.BUSITYPE,
                transfbustype: data.custData.TRANSFBUSTYPE,
                menuid: data.custData.MENUID,
                card: data.custData.CARD,
                idtype: data.custData.IDTYPE,
                idno: data.custData.IDNO,
                auth: data.custData.AUTH,
                name: data.custData.NAME,
                enname: data.custData.ENNAME,
                hometelno: data.custData.HOMETELNO,
                mobilephone: data.custData.MOBILEPHONE,
                loginid: top.softphone.loginId,
                agentname: top.softphone.agentName,
                ctino: top.softphone.agentId,
                extno: top.softphone.extNo,
                openo: top.softphone.opeNo,
                custno: data.custData.CUSTNO,
                operationtrajectory: data.custData.OPERATETRAJECT,
            },
            dataType: 'JSON',
            async: false,
            success(result) {
                if (result.code === 'success') {
                    console.info(`${top.DateUtil.now()}: ${result.msg}`);
                } else {
                    console.info(`${top.DateUtil.now()}: code=${result.code}[${result.msg}]`);
                }
            },
            error(errData) {
                console.info(`${top.DateUtil.now()}: 插入呼叫历史异常[${errData}]`);
            },
        });
    };

    /**
       * 更新转接记录
       * type 转接类型： consultAgent-转接坐席咨询,consultMeeting-会议咨询,transferTelNo-转接外线,transferAgent-转接坐席,transferIVR-转接IVR流程,transferSkill-转接技能组,meeting-会议完成,transferSatisfaction-转接满意度
       */
    this.updateTransferHistory = function (type, data) {
        $.ajax({
            type: 'POST',
            url: `${top.softphone.softPhonePath}/updateTransferCallHistory`,
            data: {
                type,
                sessionId: data.sessionId,
                ucid: data.ucid,
                contactId: data.contactId,
                originalContactId: data.originalContactId,
                callGroup: data.callGroup,
                timestamp: data.timestamp,
                ani: data.ani,
                dnis: data.dnis,
                direction: data.direction,
                sessionType: data.sessionType,
                bnknbr: top.softphone.tenantId,
                busitype: data.custData.BUSITYPE,
                transfbustype: data.custData.TRANSFBUSTYPE,
                menuid: data.custData.MENUID,
                card: data.custData.CARD,
                idtype: data.custData.IDTYPE,
                idno: data.custData.IDNO,
                auth: data.custData.AUTH,
                name: data.custData.NAME,
                enname: data.custData.ENNAME,
                hometelno: data.custData.HOMETELNO,
                mobilephone: data.custData.MOBILEPHONE,
                loginid: top.softphone.loginId,
                agentname: top.softphone.agentName,
                ctino: top.softphone.agentId,
                extno: top.softphone.extNo,
                openo: top.softphone.opeNo,
                custno: data.custData.CUSTNO,
                operationtrajectory: data.custData.OPERATETRAJECT,
            },
            dataType: 'JSON',
            async: false,
            success(result) {
                if (result.code === 'success') {
                    console.info(`${top.DateUtil.now()}: ${result.msg}`);
                } else {
                    console.info(`${top.DateUtil.now()}: code=${result.code}[${result.msg}]`);
                }
            },
            error(errData) {
                console.info(`${top.DateUtil.now()}: 插入呼叫历史异常[${errData}]`);
            },
        });
    };

    /**
       * 获取外呼sessionId
       */
    this.getOutBoundId = function () {
        top.softphone.outboundInd = top.softphone.outboundInd + 1;
        const suffInd = `0000000000${top.softphone.outboundInd}`;
        return `WH${suffInd.substr(suffInd.length - 10)}${top.softphone.agentId}${top.DateUtil.now('yyyyMMddhhmmss')}`;
    };

    /**
       * 获取离线sessionId
       */
    this.getOffLineId = function () {
        top.softphone.outboundInd = top.softphone.outboundInd + 1;
        const suffInd = `0000000000${top.softphone.outboundInd}`;
        return `LX${suffInd.substr(suffInd.length - 10)}${top.softphone.agentId}${top.DateUtil.now('yyyyMMddhhmmss')}`;
    };

    /**
       * 自助语音返回处理
       */
    this.ivrReturnToAgent = function (data) {
        console.info(`更新转接IVR流程结果:${JSON.stringify(data)}`);
        const menuid = data.MENUID;
        const msgid = data.MSGID;
        const trndri = data.TRNDRI;
        const { ucid } = data;
        const { sessionId } = data;

        /*
             * IVR正常转回坐席人工（验密、设置密码、修改密码等）
             */
        if (msgid === '101' && trndri === '2') {
            // 验证查询密码
            if (menuid === 'CONF907') // 信用卡身份验证成功
            {
                top.softphone.sessionMap[sessionId].custData.AUTH = '1';
                // 更新界面提示区
                top.softphone.showSuccInfo('身份验证', '信用卡身份验证成功！');
            }
            // 其他信用卡验证类
            else if (menuid === 'CONF908') // 信用卡CVV2验证成功
            {
                top.softphone.sessionMap[sessionId].custData.ifTrue_CVV2 = true;
                top.softphone.showSuccInfo('CVV2验证', '信用卡CVV2验证成功！');
            }
            // 验证交易密码
            else if (menuid === 'CONF909') // 信用卡交易密码验证成功
            {
                top.softphone.sessionMap[sessionId].custData.ifTrue_jyPwd = true;
                top.softphone.showSuccInfo('交易密码验证', '信用卡交易密码验证成功！');
            } else if (menuid === 'CONF901') // 信用卡查询密码设置
            {
                top.softphone.sessionMap[sessionId].custData.AUTH = '1';
                // 更新界面提示区
                top.softphone.showSuccInfo('信用卡查询密码设置', '信用卡查询密码设置成功！');
            } else if (menuid === 'CONF902') // 信用卡重置查询密码
            {
                top.softphone.sessionMap[sessionId].custData.AUTH = '1';
                // 更新界面提示区
                top.softphone.showSuccInfo('信用卡查询密码重置', '信用卡查询密码重置成功！');
            } else if (menuid === 'CONF903') // 信用卡查询密码修改
            {
                top.softphone.sessionMap[sessionId].custData.AUTH = '1';
                // 更新界面提示区
                top.softphone.showSuccInfo('信用卡查询密码修改', '信用卡查询密码修改成功！');
            } else if (menuid === 'CONF904') // 信用卡交易密码设置
            {
                top.softphone.showSuccInfo('信用卡交易密码设置', '信用卡交易密码设置成功！');
            } else if (menuid === 'CONF905') // 信用卡重置交易密码
            {
                top.softphone.showSuccInfo('信用卡交易密码重置', '信用卡交易密码重置成功！');
            } else if (menuid === 'CONF906') // 信用卡交易密码修改
            {
                top.softphone.showSuccInfo('信用卡交易密码修改', '信用卡交易密码修改成功！');
            } else if (menuid === 'CONF912') // 信用卡短信验证码验证成功
            {
                top.softphone.sessionMap[sessionId].custData.ifTrue_msgcode = true;
                top.softphone.showSuccInfo('信用卡短信验证', '信用卡短信验证码验证成功！');
            } else if (menuid === 'CONF913') // 信用卡挂失
            {
                top.softphone.showSuccInfo('信用卡挂失', '信用卡挂失成功！');
            } else if (menuid === 'CONF914') // 信用卡激活
            {
                top.softphone.showSuccInfo('信用卡激活', '信用卡激活成功！');
            } else if (menuid.substring(0, 4) == 'CONF') // 其他转接IVR
            {
                top.softphone.showSuccInfo('IVR操作结果', 'IVR操作成功！');
            }
        } else if (msgid == '102' && trndri == '2')// IVR用户挂机
        {
            // this.showNoticeInfo("失败提示", "用户已挂机请进行小结！");
        } else if (msgid == '103' && trndri == '2')// 系统错误
        {
            top.softphone.showErrorInfo('IVR操作失败提示', 'IVR系统错误！');
        } else if (msgid == '104' && trndri == '2')// IVR交易失败或异常
        {
            // 验证查询密码
            if (menuid === 'CONF907') {
                top.softphone.sessionMap[sessionId].custData.AUTH = '0';
                // 更新界面提示区
                top.softphone.showErrorInfo('身份验证失败', `${data.respcode}[${data.respdesc}]`);
            }
            // 其他信用卡验证类
            else if (menuid === 'CONF908') {
                top.softphone.sessionMap[sessionId].custData.ifTrue_CVV2 = false;
                top.softphone.showErrorInfo('CVV2验证失败', `${data.respcode}[${data.respdesc}]`);
            }
            // 验证交易密码
            else if (menuid === 'CONF909') {
                top.softphone.sessionMap[sessionId].custData.ifTrue_jyPwd = false;
                top.softphone.showErrorInfo('交易密码验证失败', `${data.respcode}[${data.respdesc}]`);
            } else if (menuid === 'CONF901') {
                // top.softphone.sessionMap[sessionId].custData.AUTH = "0";
                top.softphone.showErrorInfo('信用卡查询密码设置失败', `${data.respcode}[${data.respdesc}]`);
            } else if (menuid === 'CONF902') {
                // top.softphone.sessionMap[sessionId].custData.AUTH = "0";
                top.softphone.showErrorInfo('信用卡查询密码重置失败', `${data.respcode}[${data.respdesc}]`);
            } else if (menuid === 'CONF903') {
                // top.softphone.sessionMap[sessionId].custData.AUTH = "0";
                top.softphone.showErrorInfo('信用卡查询密码修改失败', `${data.respcode}[${data.respdesc}]`);
            } else if (menuid === 'CONF904') {
                top.softphone.showErrorInfo('信用卡交易密码设置失败', `${data.respcode}[${data.respdesc}]`);
            } else if (menuid === 'CONF905') {
                top.softphone.showErrorInfo('信用卡交易密码重置失败', `${data.respcode}[${data.respdesc}]`);
            } else if (menuid === 'CONF906') {
                top.softphone.showErrorInfo('信用卡交易密码修改失败', `${data.respcode}[${data.respdesc}]`);
            } else if (menuid === 'CONF912') {
                top.softphone.sessionMap[sessionId].userData.ifTrue_msgcode = false;
                top.softphone.showErrorInfo('信用卡短信验证失败', `${data.respcode}[${data.respdesc}]`);
            } else if (menuid === 'CONF913') {
                top.softphone.showErrorInfo('信用卡挂失失败', `${data.respcode}[${data.respdesc}]`);
            } else if (menuid === 'CONF914') {
                top.softphone.showErrorInfo('信用卡激活失败', `${data.respcode}[${data.respdesc}]`);
            } else if (menuid.substring(0, 4) == 'CONF') {
                top.softphone.showErrorInfo('IVR操作结果失败', `${data.respcode}[${data.respdesc}]`);
            }
        } else if (msgid == '105' && trndri == '2')// 返回上级菜单
        {
            // 这里无需处理
        } else if (msgid == '106' && trndri == '2')// 返回主菜单
        {
            // 这里无需处理
        } else if (msgid == '107' && trndri == '2')// 用户未核身
        {
            top.softphone.showErrorInfo('失败提示[客户未通过身份验证]', `${data.respcode}[${data.respdesc}]`);
        } else if (msgid == '108' && trndri == '2')// 按键超时
        {
            top.softphone.showErrorInfo('失败提示', '客户输入信息超时！');
        } else if (msgid == '109' && trndri == '2')// 输入次数过多
        {
            // 验证查询密码
            if (menuid === 'CONF907') {
                top.softphone.sessionMap[sessionId].custData.AUTH = '0';
                // 更新界面提示区
                if (data.respcode == null || data.respcode == '') {
                    top.softphone.showErrorInfo('失败提示[输入次数过多]', '997[输入数据格式错误或数据非法]');
                } else {
                    top.softphone.showErrorInfo('身份验证失败[输入次数过多]', `${data.respcode}[${data.respdesc}]`);
                }
            }
            // 其他信用卡验证类
            else if (menuid === 'CONF908') {
                top.softphone.sessionMap[sessionId].custData.ifTrue_CVV2 = false;
                if (data.respcode == null || data.respcode == '') {
                    top.softphone.showErrorInfo('失败提示[输入次数过多]', '997[输入数据格式错误或数据非法]');
                } else {
                    top.softphone.showErrorInfo('CVV2验证失败[输入次数过多]', `${data.respcode}[${data.respdesc}]`);
                }
            }
            // 验证交易密码
            else if (menuid === 'CONF909') {
                top.softphone.sessionMap[sessionId].custData.ifTrue_jyPwd = false;
                if (data.respcode == null || data.respcode == '') {
                    top.softphone.showErrorInfo('失败提示[输入次数过多]', '997[输入数据格式错误或数据非法]');
                } else {
                    top.softphone.showErrorInfo('交易密码验证失败[输入次数过多]', `${data.respcode}[${data.respdesc}]`);
                }
            } else if (menuid === 'CONF901') {
                // top.softphone.sessionMap[sessionId].custData.AUTH = "0";
                if (data.respcode == null || data.respcode == '') {
                    top.softphone.showErrorInfo('失败提示[输入次数过多]', '997[输入数据格式错误或数据非法]');
                } else {
                    top.softphone.showErrorInfo('信用卡查询密码设置失败[输入次数过多]', `${data.respcode}[${data.respdesc}]`);
                }
            } else if (menuid === 'CONF902') {
                // top.softphone.sessionMap[sessionId].custData.AUTH = "0";
                if (data.respcode == null || data.respcode == '') {
                    top.softphone.showErrorInfo('失败提示[输入次数过多]', '997[输入数据格式错误或数据非法]');
                } else {
                    top.softphone.showErrorInfo('信用卡查询密码重置失败[输入次数过多]', `${data.respcode}[${data.respdesc}]`);
                }
            } else if (menuid === 'CONF903') {
                // top.softphone.sessionMap[sessionId].custData.AUTH = "0";
                if (data.respcode == null || data.respcode == '') {
                    top.softphone.showErrorInfo('失败提示[输入次数过多]', '997[输入数据格式错误或数据非法]');
                } else {
                    top.softphone.showErrorInfo('信用卡查询密码修改失败[输入次数过多]', `${data.respcode}[${data.respdesc}]`);
                }
            } else if (menuid === 'CONF904') {
                if (data.respcode == null || data.respcode == '') {
                    top.softphone.showErrorInfo('失败提示[输入次数过多]', '997[输入数据格式错误或数据非法]');
                } else {
                    top.softphone.showErrorInfo('信用卡交易密码设置失败[输入次数过多]', `${data.respcode}[${data.respdesc}]`);
                }
            } else if (menuid === 'CONF905') {
                if (data.respcode == null || data.respcode == '') {
                    top.softphone.showErrorInfo('失败提示[输入次数过多]', '997[输入数据格式错误或数据非法]');
                } else {
                    top.softphone.showErrorInfo('信用卡交易密码重置失败[输入次数过多]', `${data.respcode}[${data.respdesc}]`);
                }
            } else if (menuid === 'CONF906') {
                if (data.respcode == null || data.respcode == '') {
                    top.softphone.showErrorInfo('失败提示[输入次数过多]', '997[输入数据格式错误或数据非法]');
                } else {
                    top.softphone.showErrorInfo('信用卡交易密码修改失败[输入次数过多]', `${data.respcode}[${data.respdesc}]`);
                }
            } else if (menuid === 'CONF912') {
                top.softphone.sessionMap[sessionId].custData.ifTrue_msgcode = false;
                if (data.respcode == null || data.respcode == '') {
                    top.softphone.showErrorInfo('失败提示[输入次数过多]', '997[输入数据格式错误或数据非法]');
                } else {
                    top.softphone.showErrorInfo('信用卡短信验证失败[输入次数过多]', `${data.respcode}[${data.respdesc}]`);
                }
            } else if (menuid === 'CONF913') {
                if (data.respcode == null || data.respcode == '') {
                    top.softphone.showErrorInfo('失败提示[输入次数过多]', '997[输入数据格式错误或数据非法]');
                } else {
                    top.softphone.showErrorInfo('信用卡挂失失败[输入次数过多]', `${data.respcode}[${data.respdesc}]`);
                }
            } else if (menuid === 'CONF914') {
                if (data.respcode == null || data.respcode == '') {
                    top.softphone.showErrorInfo('失败提示[输入次数过多]', '997[输入数据格式错误或数据非法]');
                } else {
                    top.softphone.showErrorInfo('信用卡激活失败[输入次数过多]', `${data.respcode}[${data.respdesc}]`);
                }
            } else if (menuid.substring(0, 4) == 'CONF') {
                if (data.respcode == null || data.respcode == '') {
                    top.softphone.showErrorInfo('失败提示[输入次数过多]', '997[输入数据格式错误或数据非法]');
                } else {
                    top.softphone.showErrorInfo('IVR操作结果失败[输入次数过多]', `${data.respcode}[${data.respdesc}]`);
                }
            }
        } else {
            // 这里无需处理
        }
    };

    /**
       * 获取所有签入坐席
       *
       */
    this.getAllLoginAgentList = function () {
        $.ajax({
            type: 'POST',
            url: `${top.softphone.softPhonePath}/getAllLoginAgentList`,
            data: {
                tenantId: top.softphone.tenantId,
                agentgroupList: JSON.stringify(top.softphone.agentgroupList),
                httpConnector: top.softphone.httpConnector,
            },
            dataType: 'JSON',
            async: false,
            success(result) {
                console.info(`${top.DateUtil.now()} 查询坐席登录列表: ${JSON.stringify(result)}`);
                return result;
            },
            error(errData) {
                console.info(`${top.DateUtil.now()}: 查询坐席登录列表失败[${errData}]`);
                return null;
            },
        });
    };
}
